package no.ntnu.fp.net.co;

import java.io.EOFException;
import java.io.IOException;
import java.util.ArrayList;

public class CoServer
{
	 public static void main (String args[])
	 {
		 ArrayList<String> messages = new ArrayList<String>();
		 
		 Connection server = new ConnectionImpl(12345);
	
		 Connection conn;
		 try 
		 {
			 conn = server.accept();

	    	try 
	    	{
	    		while (true) 
	    		{
	    			String msg = conn.receive();
	    			if(messages.contains(msg))
	    			{
	    				System.err.println("DUPLICATE MESSAGE TO APPLICATION");
	    			}
	    			messages.add(msg);
	    		}
		    }
	    	catch (EOFException e)
	    	{	
	    		conn.close();
	    		return;
		    }
		 }
		 catch (IOException e)
		 {
		      e.printStackTrace();
		 }
	 }
}
